package cn.kgc.mybatisday05.mapper;

import cn.kgc.mybatisday05.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/6/5
 * @Description: mybatis框架中的注解开发
 */
@CacheNamespace  // 开启缓存
public interface StudentMapper {

    //@Select("select *  from student")
    //@ResultMap("student")
    List<Student> getList();

    @Select("select *  from student where id = #{a}")
    @Results(id = "student", value = {
            @Result(column = "name", property = "stuName"),
            @Result(column = "id", property = "id")
    })
    Student getOne(Integer id);


    @Insert("insert into student(name,age)values(#{stuName},#{age})")
    Integer addStudent(Student student);

    @Update("update student set name = #{stuName},age = #{age} where id = #{id}")
    Integer updateStudent(Student student);

    @Delete("delete from student where id = #{id}")
    Integer deleteById(Integer id);


}
